package com.gitee.wsl.mathematics.geometry.d2

import com.gitee.wsl.mathematics.geometry.d2.rect.Rectangle
import com.gitee.wsl.mathematics.vector.vec2.Vec2f
import kotlin.test.*

class RectangleTest {

    @Test
    fun createFromAnchor() {
        val r00 = Rectangle.fromAnchor(Vec2f.ZERO, Vec2f(300.0, 300.0), 100.0f, 100.0f)
        val r11 = Rectangle.fromAnchor(Vec2f.ONE, Vec2f(300.0, 300.0), 100.0f, 100.0f)

//        assertEquals(r00.position(Vec2f.ZERO), Vec2f(300.0, 300.0))
//        assertEquals(r11.position(Vec2f.ONE), Vec2f(300.0, 300.0))

        val rcc = Rectangle.fromAnchor(Vec2f(0.5, 0.5), Vec2f(300.0, 300.0), 100.0f, 200.0f)

        assertEquals(rcc, Rectangle(250.0, 200.0, 100.0, 200.0))
        assertEquals(rcc, Rectangle.fromCenter(Vec2f(300.0, 300.0), 100.0f, 200.0f))
    }
}